package com.dnjn.happiness.emo.api.factory;

import com.dnjn.happiness.common.core.domain.R;
import com.dnjn.happiness.emo.api.RemoteRiskService;
import com.dnjn.happiness.emo.api.model.RiskVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;
@Component
public class RemoteRiskFallbackFactory implements FallbackFactory<RemoteRiskService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteRiskFallbackFactory.class);

    @Override
    public RemoteRiskService create(Throwable throwable) {
        log.error("调用Risk服务失败：{}" + throwable.getMessage());
        return new RemoteRiskService() {
            @Override
            public R<RiskVO> getByRiskType(String rtype, String source) {
                return R.fail("获取Risk列表失败：{}" + throwable.getMessage());
            }

            @Override
            public R<List<RiskVO>> getRiskAll(String source) {
                return R.fail("获取Risk列表失败：{}" + throwable.getMessage());
            }
        };
    }

}
